package com.jsyl.lwbk.web.controller.business;

import com.jsyl.lwbk.business.dto.ChildAnswerDTO;
import com.jsyl.lwbk.business.service.IChildRecordService;
import com.jsyl.lwbk.common.core.controller.BaseController;
import com.jsyl.lwbk.common.core.domain.AjaxResult;
import com.jsyl.lwbk.framework.util.ShiroUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Api("小孩记录")
@Controller
@RequestMapping("/business/childRecord")
public class ChildRecordController extends BaseController {

    @Autowired
    IChildRecordService childRecordService;

    @ApiOperation(value = "学习列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "childId", value = "小孩id"),
            @ApiImplicitParam(name = "evaluateNumber", value = "测评编号"),
            @ApiImplicitParam(name = "questionId", value = "题目id"),
            @ApiImplicitParam(name = "answerSore", value = "答案分数"),
            @ApiImplicitParam(name = "selectCenterId", value = "中心id")
    })
    @ResponseBody
    @PostMapping("/saveChildRecord")
    public AjaxResult saveChildRecord(@RequestBody ChildAnswerDTO childAnswerDTO) {
        String createName = ShiroUtils.getLoginName();
        String evaluateNumber = childRecordService.saveChildRecord(childAnswerDTO, createName);
        return success(evaluateNumber);
    }

    @ApiOperation(value = "历史得分")
    @ResponseBody
    @GetMapping("/oldChildScore")
    public AjaxResult oldChildScore() {
        childRecordService.saveOldChildScore();
        return success();
    }

    @ApiOperation(value = "历史数据")
    @ResponseBody
    @GetMapping("/oldData")
    public AjaxResult oldData() {
        childRecordService.saveOldChildRecord();
        return success();
    }

}
